package top.haijunit.common.response;

import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import top.haijunit.common.response.advice.GlobalExceptionAdvice;
import top.haijunit.common.response.advice.GlobalRestResultWrapper;

/**
 * 全局返回值处理的自动配置
 *
 * @author zhanghaijun
 * @date 2024/6/6 13:12
 * @description [一句话描述该类的功能]
 */
@Configuration
@Import(JacksonConfig.class)
public class ResponseConfigurer {

    @Bean
    @ConditionalOnMissingBean(value = GlobalExceptionAdvice.class)
    public GlobalExceptionAdvice grGlobalExceptionAdvice() {
        return new GlobalExceptionAdvice();
    }


    @Bean
    @ConditionalOnMissingBean(GlobalRestResultWrapper.class)
    public GlobalRestResultWrapper grNotVoidResponseBodyAdvice() {
        return new GlobalRestResultWrapper();
    }
}
